package com.dxl.entity.common;

import java.io.Serializable;
import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

import com.alibaba.fastjson.JSONObject;
import com.dxl.common.enums.State;
import com.dxl.common.json.JsonDateTimeSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * 实体基类
 * @author 邓小林
 */
public abstract class BaseEntity implements Serializable {
	private static final long serialVersionUID = 2151647464595087315L;
	
	public static final String FIELD_ID = "id";
	public static final String FIELD_CREATEDTIME = "createdTime";
	public static final String FIELD_UPDATEDTIME = "updatedTime";
	
	/**
	 * 主键ID
	 */
	private String id;
	/**
	 * 操作人
	 */
	private String operator;
	/**
	 * 状态，见State
	 */
	private Integer state = State.ACTIVE.getState();
	/**
	 * 创建时间
	 */
	@JsonSerialize(using=JsonDateTimeSerializer.class)
	@DateTimeFormat(iso=ISO.DATE_TIME, pattern="yyyy-MM-dd HH:mm:ss")
	private Date createdTime;
	/**
	 * 更新时间
	 */
	@JsonSerialize(using=JsonDateTimeSerializer.class)
	@DateTimeFormat(iso=ISO.DATE_TIME, pattern="yyyy-MM-dd HH:mm:ss")
	private Date updatedTime; // 更新时间
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getOperator() {
		return operator;
	}
	public void setOperator(String operator) {
		this.operator = operator;
	}
	public Integer getState() {
		return state;
	}
	public void setState(Integer state) {
		this.state = state;
	}
	public Date getCreatedTime() {
		return createdTime;
	}
	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}
	public Date getUpdatedTime() {
		return updatedTime;
	}
	public void setUpdatedTime(Date updatedTime) {
		this.updatedTime = updatedTime;
	}
	@Override
	public String toString() {
		return JSONObject.toJSONString(this);
	}
}
